<?php
/**
 * Note: 应用资源
 * Date: 2021/7/12
 */
namespace App\Http\Controllers\Admin;

use App\Models\Game\Center\AppResource;
use Illuminate\Http\Request;

class AppResourceController extends CurdController
{
    protected string $classModel = AppResource::class;

    protected array $searchFields = [
        'source' => self::FIELD_TYPE_NORMAL,
        'os' => self::FIELD_TYPE_NORMAL,
        'status' => self::FIELD_TYPE_NUMERIC,
    ];

    /**
     * 保存之前
     * @param Request $request
     */
    public function storeBefore(Request $request)
    {
        $request->validate([
            'os' => 'required|numeric',
            'is_debug' => 'sometimes|numeric',
            'url' => 'sometimes|url',
            'status' => 'sometimes|numeric',
            'version' => 'sometimes|version',
            'min_version' => 'sometimes|version',
        ]);
    }

    /**
     * 更新之前
     * @param Request $request
     */
    public function updateBefore(Request $request)
    {
        $request->validate([
            'os' => 'required|numeric',
            'is_debug' => 'sometimes|numeric',
            'url' => 'sometimes|url',
            'status' => 'sometimes|numeric',
            'version' => 'sometimes|version',
            'min_version' => 'sometimes|version',
        ]);
    }
}
